﻿using isvn.Helper;
using isvn.Commands;

namespace isvn.Base
{
    internal abstract class CommandBase : ICommand
    {
        public abstract string CmdName { get; }

        public virtual bool ValidateArgs(string[] args)
        {
            if (null == args || 0 == args.Length)
                return false;

            CommandFactory.FormatArgs(args);
            if (string.IsNullOrEmpty(args[0]) || 0 != string.Compare(CmdName, args[0], true))
                return false;

            return true;
        }

        public virtual void Help()
        {
            Output.WriteHelp(@"isvn, verion 1.0
Sub commands:
    empty   remove all files of specified directory except subversion ones.
    xcopy   copy files and directory trees.

For help of each sub commands, type: isvn help [cmd]
");
        }

        public abstract void Execute(string[] args);
    }
}
